<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:p="http://primefaces.org/ui"
                xmlns:o="http://omnifaces.org/ui"
                xmlns:jsf="http://xmlns.jcp.org/jsf">
    <!-- TERMS -->
    <ui:param name="toaNotEmpty" value="#{!empty termsOfUseAndAccess.termsOfAccess
                                        or !empty termsOfUseAndAccess.dataAccessPlace 
                                        or !empty termsOfUseAndAccess.originalArchive or !empty termsOfUseAndAccess.availabilityStatus 
                                        or !empty termsOfUseAndAccess.contactForAccess or !empty termsOfUseAndAccess.sizeOfCollection 
                                        or !empty termsOfUseAndAccess.studyCompletion
                                        }"/>
    
    <div class="text-right margin-bottom" 
         jsf:rendered="#{dataverseSession.user.authenticated and empty editMode and !widgetWrapper.widgetView
                         and permissionsWrapper.canIssueUpdateDatasetCommand(DatasetPage.dataset)}">
        <p:commandLink styleClass="btn btn-default btn-access" actionListener="#{DatasetPage.edit('LICENSE')}" 
                       update="@form,:messagePanel" disabled="#{DatasetPage.lockedFromEdits}">
            <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
            <span class="glyphicon glyphicon-briefcase"/> #{bundle['file.dataFilesTab.terms.editTermsBtn']}
        </p:commandLink>
    </div>
    <div class="panel-group">
       <div class="panel panel-default">
           <div data-toggle="collapse" data-target="#panelCollapseTOU" class="panel-heading text-info">
               #{bundle['file.dataFilesTab.terms.list.termsOfUse.header']} &#160;<span class="glyphicon glyphicon-chevron-up"/>
           </div>
           <div id="panelCollapseTOU" class="collapse in">
               <p:fragment id="touFragment">
                   <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker"/>
                   <o:importFunctions type="org.apache.commons.text.StringEscapeUtils" />
                   <o:importFunctions type="edu.harvard.iq.dataverse.dataset.DatasetUtil" />
                   <div class="panel-body">
                       <div class="form-group">
                           <label for="datasetForm:tabView:metadata_Terms" class="col-sm-3 control-label">
                               #{bundle['file.dataFilesTab.terms.list.license']}
                           </label>
                           <div class="col-sm-9">
                               <ui:fragment rendered="#{empty editMode}">
                                   <p class="help-block">
                                       <h:outputText value="#{bundle['file.dataFilesTab.terms.list.license.view.description']}" escape="false"/>
                                   </p>
                               </ui:fragment>
                               <ui:fragment rendered="#{datasetPage == true and empty editMode and empty termsOfUseAndAccess.license}">
                                   <p>
                                       <h:outputText value="#{DatasetUtil:getLicenseName(DatasetPage.workingVersion).concat(' ')}" escape="false"/>
                                       <h:outputText rendered="#{!datasetVersionServiceBean.isVersionDefaultCustomTerms(DatasetPage.workingVersion)}" value="#{bundle['file.dataFilesTab.terms.list.license.customterms.txt']}" escape="false"/>
                                   </p>
                               </ui:fragment>
                               <ui:fragment rendered="#{!empty editMode}">
                                   <p class="help-block"><h:outputText value="#{bundle['file.dataFilesTab.terms.list.license.edit.description']}" escape="false"/></p>

                                   <p:selectOneMenu id="licenses" value="#{termsOfUseAndAccess.license}" style="width: 40%" converter="licenseConverter">
                                       <c:if test="#{!datasetPage}">
                                       <f:selectItems value="#{licenseServiceBean.listAllActive()}" 
                                                   var="license" itemLabel="#{DatasetUtil:getLocalizedLicenseDetails(license, 'NAME')}" itemValue="#{license}"/>
                                       </c:if>
                                       <c:if test="#{datasetPage}">
                                       <f:selectItems value="#{DatasetPage.availableLicenses}" 
                                                   var="license" itemLabel="#{DatasetUtil:getLocalizedLicenseDetails(license, 'NAME')}" itemValue="#{license}"/>
                                       </c:if>
                                       <c:if test="#{settingsWrapper.customLicenseAllowed}">
                                           <f:selectItem itemLabel="#{bundle['license.custom']}" itemValue="#{null}"/>
                                       </c:if>
                                       <p:ajax update="touFragment" />
                                       <f:passThroughAttribute name="aria-label" value="#{bundle['file.dataFilesTab.terms.list.license']}"/>
                                   </p:selectOneMenu>
                               </ui:fragment>
                               <ui:fragment rendered="#{!empty termsOfUseAndAccess.license}">
                                   <p>
                                       <img src="#{termsOfUseAndAccess.license.iconUrl}" title="#{DatasetUtil:getLocalizedLicenseDetails(termsOfUseAndAccess.license, 'DESCRIPTION')}"  style="display:none"  onload="this.style.display='inline'" />
                                       <a href="#{termsOfUseAndAccess.license.uri}" title="#{DatasetUtil:getLocalizedLicenseDetails(termsOfUseAndAccess.license,'DESCRIPTION')}" target="_blank">#{DatasetUtil:getLocalizedLicenseDetails(termsOfUseAndAccess.license,'NAME')}</a>
                                   </p>
                               </ui:fragment>
                           </div>
                       </div>

                       <!-- Additional Information -->
                        <ui:fragment rendered="#{empty editMode and empty termsOfUseAndAccess.license}">
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.termsOfUse}">
                                <label for="datasetForm:tabView:metadata_TermsUse" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.termsOfUse']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.termsOfUse.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.termsOfUse)}" escape="false"/>
                               </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.confidentialityDeclaration}">
                                <label for="datasetForm:tabView:confidentialityDeclarationText" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.declaration']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.declaration.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText id="confidentialityDeclarationText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.confidentialityDeclaration)}" escape="false"/>
                                </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.specialPermissions}">
                                <label for="datasetForm:tabView:specialPermissionsText" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.permissions']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.permissions.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText id="specialPermissionsText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.specialPermissions)}" escape="false"/>
                                </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.restrictions}">
                                <label for="datasetForm:tabView:restrictionsText" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.restrictions']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.restrictions.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText id="restrictionsText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.restrictions)}" escape="false"/>
                                </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.citationRequirements}">
                                <label for="datasetForm:tabView:citationRequirementsText" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.citationRequirements']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.citationRequirements.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText id="citationRequirementsText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.citationRequirements)}" escape="false"/>
                                </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.depositorRequirements}">
                                <label for="datasetForm:tabView:depositorRequirementsText" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.depositorRequirements']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.depositorRequirements.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText id="depositorRequirementsText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.depositorRequirements)}" escape="false"/>
                                </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.conditions}">
                                <label for="datasetForm:tabView:conditionsText" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.conditions']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.conditions.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText id="conditionsText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.conditions)}" escape="false"/>
                                </div>
                            </div>
                            <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.disclaimer}">
                                <label for="datasetForm:tabView:disclaimerText" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.disclaimer']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.disclaimer.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <h:outputText id="disclaimerText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.disclaimer)}" escape="false"/>
                                </div>
                            </div>
                        </ui:fragment>
                        <ui:fragment rendered="#{!empty editMode and termsOfUseAndAccess.license == null}">
                            <div class="form-group">
                                <label jsf:for="dlTermsdOfUse" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.termsOfUse']}
                                    <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/>
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.termsOfUse.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="dlTermsdOfUse" value="#{termsOfUseAndAccess.termsOfUse}" rows="5" cols="60" styleClass="form-control" title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.termsOfUse']}" 
                                                     validator="#{DatasetPage.validateTerms}">
                                    </p:inputTextarea>
                                    <h:message for="metadata_TermsUse" styleClass="bg-danger text-danger"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="datasetForm:tabView:confidentialityDeclaration" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.declaration']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.declaration.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="confidentialityDeclaration" value="#{termsOfUseAndAccess.confidentialityDeclaration}" rows="5" cols="60" styleClass="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="datasetForm:tabView:specialPermissions" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.permissions']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.permissions.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="specialPermissions" value="#{termsOfUseAndAccess.specialPermissions}" rows="5" cols="60" styleClass="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="datasetForm:tabView:restrictions" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.restrictions']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.restrictions.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="restrictions" value="#{termsOfUseAndAccess.restrictions}" rows="5" cols="60" styleClass="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="datasetForm:tabView:citationRequirements" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.citationRequirements']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.citationRequirements.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="citationRequirements" value="#{termsOfUseAndAccess.citationRequirements}" rows="5" cols="60" styleClass="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="datasetForm:tabView:depositorRequirements" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.depositorRequirements']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.depositorRequirements.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="depositorRequirements" value="#{termsOfUseAndAccess.depositorRequirements}" rows="5" cols="60" styleClass="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="datasetForm:tabView:conditions" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.conditions']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.conditions.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="conditions" value="#{termsOfUseAndAccess.conditions}" rows="5" cols="60" styleClass="form-control" />
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="datasetForm:tabView:disclaimer" class="col-sm-3 control-label">
                                    #{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.disclaimer']}
                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                          data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfUse.addInfo.disclaimer.title']}"></span>
                                </label>
                                <div class="col-sm-9">
                                    <p:inputTextarea id="disclaimer" value="#{termsOfUseAndAccess.disclaimer}" rows="5" cols="60" styleClass="form-control" />
                                </div>
                            </div>
                        </ui:fragment>
                        <!-- END: Additional Information -->
                    </div>
                </p:fragment>
            </div>
        </div>
       <div class="panel panel-default" jsf:rendered="#{managePage==true or !empty editMode or (datasetPage == true and DatasetPage.restrictedFileCount > 0) 
                                                        or toaNotEmpty}">
           <div data-toggle="collapse" data-target="#panelCollapseTOA" class="panel-heading text-info">
               <h:outputText value="#{publicStore ? bundle['file.dataFilesTab.terms.list.termsOfAccess.termsOfsAccess'] : bundle['file.dataFilesTab.terms.list.termsOfAccess.header']}"/>
               &#160;<span class="glyphicon glyphicon-chevron-up"/>
           </div>
           <div id="panelCollapseTOA" class="panel-collapse #{!empty editMode or (datasetPage == false and toaNotEmpty )  or (datasetPage == true and DatasetPage.hasValidTermsOfAccess) ? 'collapse in' : 'collapse'}">
               <div class="panel-body">
                   <ui:fragment rendered="#{empty editMode}">
                       <div class="form-group" jsf:rendered="#{!publicStore  and datasetPage== true and DatasetPage.hasRestrictedFiles}">
                           <label for="datasetForm:tabView:metadata_RestrictedFiles" class="col-sm-3 control-label">
                               #{bundle['file.dataFilesTab.terms.list.termsOfAccess.restrictedFiles']}
                               <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                     data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.restrictedFiles.title']}"></span>
                           </label>
                           <ui:fragment rendered="#{datasetPage == true}">
                               <div class="col-sm-9">
                                   <p>
                                       <h:outputFormat id="metadata_RestrictedFiles" value="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.restrictedFiles.txt']}">
                                           <f:param value="#{DatasetPage.restrictedFileCount}"/>
                                       </h:outputFormat>
                                   </p>
                               </div>
                           </ui:fragment>
                       </div>
                       <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.termsOfAccess and (DatasetPage.restrictedFileCount > 0 or managePage==true)}">
                           <label for="datasetForm:tabView:metadata_TermsAccessText" class="col-sm-3 control-label">
                               #{bundle['file.dataFilesTab.terms.list.termsOfAccess.termsOfsAccess']}
                               <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                     data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.termsOfsAccess.title']}"></span>
                           </label>
                           <div class="col-sm-9">
                               <p><h:outputText id="metadata_TermsAccessText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.termsOfAccess)}" escape="false"/></p>
                           </div>
                       </div>
                       <div class="form-group" jsf:rendered="#{!publicStore and ((datasetPage == true and DatasetPage.hasRestrictedFiles) or managePage==true)}">
                           <label for="datasetForm:tabView:metadata_RequestAccessSelected" class="col-sm-3 control-label">
                               #{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess']}
                               <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                     data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.title']}"></span>
                           </label>
                           <div id="metadata_RequestAccessSelected" class="col-sm-9">
                               <p jsf:rendered="#{datasetPage == true and !DatasetPage.workingVersion.draft}">
                                   <h:outputText value="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.request']}" rendered="#{DatasetPage.dataset.fileAccessRequest}"/>
                                   <h:outputText value="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.notRequest']}" rendered="#{!DatasetPage.dataset.fileAccessRequest}"/>
                               </p>
                               <p jsf:rendered="#{(datasetPage == true and DatasetPage.workingVersion.draft) or managePage==true}">
                                   <h:outputText value="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.request']}" rendered="#{termsOfUseAndAccess.fileAccessRequest}"/>
                                   <h:outputText value="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.notRequest']}" rendered="#{!termsOfUseAndAccess.fileAccessRequest}"/>
                               </p>
                           </div>
                       </div>
                   </ui:fragment>
                   <ui:fragment rendered="#{!empty editMode}">
                        <div class="form-group" jsf:rendered="#{!publicStore}"> 
                            <p:fragment id="termsOfAccessHelp">
                                <ui:fragment rendered="#{datasetPage == true and DatasetPage.hasRestrictedFiles}">
                                    <div class="alert alert-info">
                                        <span class="glyphicon glyphicon-info-sign"></span>&#160;<strong>#{bundle['messages.info']}</strong> –
                                        <h:outputText value=" #{bundle['file.dataFilesTab.terms.list.termsOfAccess.description']}"/>
                                        <h:outputFormat value=" #{bundle['file.dataFilesTab.terms.list.termsOfAccess.description.line.2']}" escape="false">
                                            <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                            <f:param value="#{systemConfig.guidesVersion}"/>
                                        </h:outputFormat>
                                    </div>
                                </ui:fragment>
                            </p:fragment>    
                           <label for="datasetForm:tabView:requestAccess" class="col-sm-3 control-label">
                               #{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess']}
                               <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                     data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.title']}"></span>
                           </label>
                           <div class="col-sm-9">
                                <p:selectBooleanCheckbox id="requestAccess" itemLabel="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.enableBtn']}" 
                                                        value="#{termsOfUseAndAccess.fileAccessRequest}" disabled="#{datasetPage == true and !DatasetPage.hasRestrictedFiles}">
                                   <p:ajax event="change" update="termsOfAccessHelp" />
                               </p:selectBooleanCheckbox>                                                          
                           </div>
                       </div>
                       <p:fragment id="toaValidation">
                           <div  class="ui-message ui-message-error ui-widget ui-corner-all" aria-live="polite" jsf:rendered="#{datasetPage == true and DatasetPage.hasRestrictedFiles and empty termsOfUseAndAccess.termsOfAccess  and !termsOfUseAndAccess.fileAccessRequest}">
                               <span class="ui-message-error-detail">#{bundle['file.dataFilesTab.terms.list.termsOfAccess.requestAccess.warning.outofcompliance']}</span>          
                           </div>
                       </p:fragment>
                       <div class="form-group">
                           <label for="datasetForm:tabView:metadata_TermsAccess" class="col-sm-3 control-label">
                               #{bundle['file.dataFilesTab.terms.list.termsOfAccess.termsOfsAccess']}
                               <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                     data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.termsOfsAccess.title']}"></span>
                           </label>
                           <div class="col-sm-9">
                                <p:inputTextarea  id="metadata_TermsAccess" value="#{termsOfUseAndAccess.termsOfAccess}" 
                                                  rows="5" styleClass="form-control" disabled="#{datasetPage == true and !DatasetPage.hasRestrictedFiles}" />

                           </div>
                       </div>
                    <p:fragment>
                        <p:autoUpdate/>
                        <o:inputHidden id="termsofAccessHiddenLT" value="#{termsOfUseAndAccess.termsOfAccess}" />
                        <o:inputHidden id="fileAccessRequestHiddenLT" value="#{termsOfUseAndAccess.fileAccessRequest}" />
                     </p:fragment>

                   </ui:fragment>

                    <!-- Additional Information -->
                    <ui:fragment rendered="#{empty editMode}">
                        <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.dataAccessPlace}">
                            <label for="datasetForm:tabView:dataAccessPlaceText" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.dataAccessPlace']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.dataAccessPlace.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <h:outputText id="dataAccessPlaceText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.dataAccessPlace)}" escape="false"/>
                            </div>
                        </div>
                        <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.originalArchive}">
                            <label for="datasetForm:tabView:originalArchiveText" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.originalArchive']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.originalArchive.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <h:outputText id="originalArchiveText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.originalArchive)}" escape="false"/>
                            </div>
                        </div>
                        <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.availabilityStatus}">
                            <label for="datasetForm:tabView:availabilityStatusText" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.availabilityStatus']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.availabilityStatus.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <h:outputText id="availabilityStatusText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.availabilityStatus)}" escape="false"/>
                            </div>
                        </div>
                        <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.contactForAccess}">
                            <label for="datasetForm:tabView:contactForAccessText" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.contactForAccess']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.contactForAccess.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <h:outputText id="contactForAccessText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.contactForAccess)}" escape="false"/>
                            </div>
                        </div>
                        <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.sizeOfCollection}">
                            <label for="datasetForm:tabView:collectionSizeText" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.sizeOfCollection']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.sizeOfCollection.tip']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <h:outputText id="collectionSizeText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.sizeOfCollection)}" escape="false"/>
                            </div>
                        </div>
                        <div class="form-group" jsf:rendered="#{!empty termsOfUseAndAccess.studyCompletion}">
                            <label for="datasetForm:tabView:studyCompletionText" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <h:outputText id="studyCompletionText" value="#{MarkupChecker:sanitizeBasicHTML(termsOfUseAndAccess.studyCompletion)}" escape="false"/>
                            </div>
                        </div>
                    </ui:fragment>
                    <ui:fragment rendered="#{!empty editMode}">
                        <div class="form-group">
                            <label for="datasetForm:tabView:dataAccessPlace" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.dataAccessPlace']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.dataAccessPlace.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <p:inputTextarea id="dataAccessPlace" value="#{termsOfUseAndAccess.dataAccessPlace}" rows="5" cols="60" styleClass="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="datasetForm:tabView:originalArchive" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.originalArchive']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.originalArchive.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <p:inputTextarea id="originalArchive" value="#{termsOfUseAndAccess.originalArchive}" rows="5" cols="60" styleClass="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="datasetForm:tabView:availabilityStatus" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.availabilityStatus']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.availabilityStatus.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <p:inputTextarea id="availabilityStatus" value="#{termsOfUseAndAccess.availabilityStatus}" rows="5" cols="60" styleClass="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="datasetForm:tabView:contactForAccess" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.contactForAccess']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.contactForAccess.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <p:inputTextarea id="contactForAccess" value="#{termsOfUseAndAccess.contactForAccess}" rows="5" cols="60" styleClass="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="datasetForm:tabView:sizeOfCollection" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.sizeOfCollection']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.sizeOfCollection.tip']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <p:inputTextarea id="sizeOfCollection" value="#{termsOfUseAndAccess.sizeOfCollection}" rows="5" cols="60" styleClass="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="datasetForm:tabView:studyCompletion" class="col-sm-3 control-label">
                                #{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.termsOfAccess.addInfo.studyCompletion.title']}"></span>
                            </label>
                            <div class="col-sm-9">
                                <p:inputTextarea id="studyCompletion" value="#{termsOfUseAndAccess.studyCompletion}" rows="5" cols="60" styleClass="form-control" />
                            </div>
                        </div>
                    </ui:fragment>
                    <!-- END: Additional Information -->
                </div>
            </div>
        </div>

        <div class="panel panel-default" jsf:rendered="#{!settingsWrapper.rsyncOnly and (managePage==false or datasetPage == true)
                                                         and (!empty DatasetPage.dataset.guestbook or (dataverseSession.user.authenticated and permissionsWrapper.canIssueUpdateDatasetCommand(DatasetPage.dataset)))}">
           <div data-toggle="collapse" data-target="#panelCollapseGuestbook" class="panel-heading text-info">
               #{bundle['file.dataFilesTab.terms.list.guestbook']} &#160;<span class="glyphicon glyphicon-chevron-down"/>
           </div>
           <div id="panelCollapseGuestbook" class="collapse">
               <div class="panel-body">
                   <div class="form-group">
                       <label for="datasetForm:tabView:metadata_Guestbook" class="col-sm-3 control-label">
                           #{bundle['file.dataFilesTab.terms.list.guestbook']}
                           <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                 data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['file.dataFilesTab.terms.list.guestbook.title']}"></span>
                       </label>
                       <div id="metadata_Guestbook" class="col-sm-9">
                           <ui:fragment rendered="#{empty editMode}">
                               <ui:fragment rendered="#{ datasetPage and empty DatasetPage.dataset.guestbook 
                                                        and ((!dataverseSession.user.authenticated or !permissionsWrapper.canIssueUpdateDatasetCommand(DatasetPage.dataset))
                                                        or ((dataverseSession.user.authenticated and permissionsWrapper.canIssueUpdateDatasetCommand(DatasetPage.dataset) 
                                                           and !empty DatasetPage.dataset.dataverseContext.availableGuestbooks)))}">
                                   <p class="help-block">
                                       #{bundle['file.dataFilesTab.terms.list.guestbook.noSelected.tip']}
                                       <h:outputFormat value="#{bundle['dataset.manageGuestbooks.noGuestbooks.learnMore']}" escape="false">
                                           <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                           <f:param value="#{systemConfig.guidesVersion}"/>
                                       </h:outputFormat>
                                   </p>
                               </ui:fragment>
                               <ui:fragment rendered="#{empty DatasetPage.dataset.guestbook 
                                                 and (dataverseSession.user.authenticated and permissionsWrapper.canIssueUpdateDatasetCommand(DatasetPage.dataset))
                                                 and empty DatasetPage.dataset.dataverseContext.availableGuestbooks}">
                                   <p>
                                       <h:outputFormat value="#{bundle['file.dataFilesTab.terms.list.guestbook.noSelected.admin.tip']}">
                                           <f:param value="#{DatasetPage.dataset.owner.name}"/>
                                       </h:outputFormat>
                                   </p>
                               </ui:fragment>

                               <ui:fragment rendered="#{!empty DatasetPage.dataset.guestbook}">
                                   <p class="help-block">#{bundle['file.dataFilesTab.terms.list.guestbook.inUse.tip']}</p>
                                   <div class="panel panel-default">
                                       <div class="panel-body">
                                           <p class="form-control-static pull-left">#{DatasetPage.dataset.guestbook.name}</p>
                                           <p:commandButton styleClass="btn btn-default pull-right"
                                                          value="#{bundle['file.dataFilesTab.terms.list.guestbook.viewBtn']}"
                                                          action="#{DatasetPage.viewSelectedGuestbook(DatasetPage.dataset.guestbook)}"
                                                          update=":datasetForm:previewGuestbook" oncomplete="PF('viewGuestbook').show();"/>
                                       </div>
                                   </div>
                               </ui:fragment>
                           </ui:fragment>
                           <ui:fragment rendered="#{!empty editMode and datasetPage}">
                               <p class="help-block">
                                   #{bundle['file.dataFilesTab.terms.list.guestbook.select.tip']}
                                       <h:outputFormat value=" #{bundle['dataset.manageGuestbooks.noGuestbooks.learnMore']}" escape="false">
                                            <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                            <f:param value="#{systemConfig.guidesVersion}"/>
                                        </h:outputFormat>
                               </p>

                                <ui:fragment rendered="#{empty DatasetPage.dataset.dataverseContext.availableGuestbooks}">
                                    <p class="help-block">
                                        <h:outputFormat value="#{bundle['file.dataFilesTab.terms.list.guestbook.noAvailable.tip']}">
                                            <f:param value="#{DatasetPage.dataset.owner.name}"/>
                                        </h:outputFormat>
                                    </p>
                                </ui:fragment>

                               <ui:fragment rendered="#{!empty DatasetPage.dataset.dataverseContext.availableGuestbooks}">
                                   <p:commandButton styleClass="btn btn-default"
                                                    value="#{bundle['file.dataFilesTab.terms.list.guestbook.clearBtn']}" 
                                                    rendered="#{!empty DatasetPage.dataset.guestbook}"
                                                    update="guestbookTable" process="@this" oncomplete="PF('guestbookTable').unselectAllRows();" actionListener="#{DatasetPage.reset}"/>
                                   <p:dataTable id="guestbookTable" styleClass="headerless-table margin-top"
                                                value="#{DatasetPage.dataset.dataverseContext.availableGuestbooks}" var="guestbook" widgetVar="guestbookTable"
                                                rendered="#{!empty DatasetPage.dataset.dataverseContext.availableGuestbooks}"
                                                rowIndexVar="rowNum" selection="#{DatasetPage.dataset.guestbook}" rowKey="#{guestbook}">
                                       <p:column selectionMode="single" class="col-select-width text-center"/>
                                       <p:column>
                                           <p class="form-control-static pull-left">
                                               <h:outputText value="#{guestbook.name}"/>
                                           </p>
                                           <p:commandButton styleClass="btn btn-default pull-right"
                                                          value="#{bundle['file.dataFilesTab.terms.list.guestbook.viewBtn']}"
                                                          action="#{DatasetPage.viewSelectedGuestbook(guestbook)}"
                                                          update=":datasetForm:previewGuestbook" oncomplete="PF('viewGuestbook').show();"/>
                                       </p:column>
                                   </p:dataTable>
                               </ui:fragment>
                           </ui:fragment>
                       </div>
                   </div>
               </div>
           </div>
       </div> 
    </div>
    <!-- / TERMS -->


    <!-- / Preview Guestbook -->
</ui:composition>
